﻿<ResourceDictionary xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
        xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" xmlns:models="clr-namespace:Passwords.Models"
        xmlns:vm="clr-namespace:Passwords.ViewModels" xmlns:controls="clr-namespace:Passwords.Controls"
        xmlns:d="http://schemas.microsoft.com/expression/blend/2008">
    <ControlTemplate x:Key="CompactPasswordsTemplate" TargetType="{x:Type UserControl}">
        <ControlTemplate.Resources>
            <ExponentialEase x:Key="easeOut" EasingMode="EaseOut" Exponent="5.0" />
            <ExponentialEase x:Key="easeIn" EasingMode="EaseIn" Exponent="5.0" />

            <DataTemplate x:Key="compactPasswordTemplate">
                <Grid>
                    <Grid.ColumnDefinitions>
                        <ColumnDefinition Width="auto" />
                        <ColumnDefinition Width="*" />
                    </Grid.ColumnDefinitions>
                    <Grid.InputBindings>
                        <MouseBinding Gesture="LeftDoubleClick" Command="{x:Static vm:Commands.ViewPasswordCommand}" />
                    </Grid.InputBindings>
                    <Border Background="Transparent" Width="24" Height="24">
                        <Image x:Name="img" Source="/Passwords;component/Images/Lock.png" />
                    </Border>
                    <TextBlock Grid.Column="1" Text="{Binding Name}" FontSize="14" Margin="5,2,4,2"
                            SnapsToDevicePixels="True" />
                </Grid>
                <DataTemplate.Triggers>
                    <DataTrigger  Binding="{Binding IsFavorite}" Value="true">
                        <Setter Property="Source" TargetName="img" Value="/Passwords;component/Images/appbar.favs.rest.png"/>
                    </DataTrigger>
                </DataTemplate.Triggers>
            </DataTemplate>

        </ControlTemplate.Resources>
        <Grid UseLayoutRounding="True" Focusable="True" x:Name="grid">
            <Grid.InputBindings>
                <KeyBinding Key="Enter" Command="{x:Static vm:Commands.ViewPasswordCommand}" />
            </Grid.InputBindings>
            <Grid.RowDefinitions>
                <RowDefinition Height="70" />
                <RowDefinition Height="auto" />
                <RowDefinition Height="*" />
                <RowDefinition Height="auto" />
            </Grid.RowDefinitions>

            <!--Header: -->
            <Grid Grid.Row="0" Margin="10,5,10,-5">
                <Grid.Resources>
                    <Style TargetType="RadioButton" BasedOn="{StaticResource buttonRadioStyle}" />
                </Grid.Resources>
                <TextBlock Text="{Binding rs.PasswordsTitle, Source={StaticResource locale}}" FontSize="48" FontWeight="Light" VerticalAlignment="Top"
                        Margin="0,-25,25,20" />

                <StackPanel Orientation="Horizontal" VerticalAlignment="Bottom" HorizontalAlignment="Left"
                        Margin="0,5,0,12" IsManipulationEnabled="True" x:Name="tabPanel">
                    <StackPanel.Resources>
                        <Style TargetType="Button">
                            <Setter Property="Foreground" Value="{DynamicResource AppForeground}" />
                            <Setter Property="FontSize" Value="10" />
                            <Setter Property="FontWeight" Value="Bold" />
                            <Setter Property="Margin" Value="0,0,16,0" />
                            <Setter Property="ClickMode" Value="Press" />
                            <Setter Property="Template">
                                <Setter.Value>
                                    <ControlTemplate TargetType="Button">
                                        <Border Margin="{TemplateBinding Padding}">
                                            <ContentControl Content="{TemplateBinding Content}" VerticalAlignment="Top"
                                                    HorizontalAlignment="Left" />
                                        </Border>
                                    </ControlTemplate>
                                </Setter.Value>
                            </Setter>
                        </Style>
                    </StackPanel.Resources>
                    <RadioButton x:Name="alpha" Content="{Binding rs.AlphabeticBtn, Source={StaticResource locale}}" Style="{StaticResource textRadioStyle}"
                            IsChecked="{Binding DisplayMode, Converter={StaticResource modeToBool}, ConverterParameter={x:Static models:DisplayMode.Passwords}}">
                        <RadioButton.RenderTransform>
                            <TranslateTransform />
                        </RadioButton.RenderTransform>
                    </RadioButton>
                    <Separator Style="{StaticResource lineSepStyle}" x:Name="catsSep">
                        <Separator.RenderTransform>
                            <TranslateTransform />
                        </Separator.RenderTransform>
                    </Separator>
                    <RadioButton x:Name="cats" Content="{Binding rs.CategoriesBtn, Source={StaticResource locale}}" Style="{StaticResource textRadioStyle}"
                            IsChecked="{Binding DisplayMode, Converter={StaticResource modeToBool}, ConverterParameter={x:Static models:DisplayMode.Categories}}">
                        <RadioButton.RenderTransform>
                            <TranslateTransform />
                        </RadioButton.RenderTransform>
                    </RadioButton>
                    <Separator Style="{StaticResource lineSepStyle}" x:Name="favesSep">
                        <Separator.RenderTransform>
                            <TranslateTransform />
                        </Separator.RenderTransform>
                    </Separator>
                    <RadioButton x:Name="faves" Content="{Binding rs.FavoritesBtn, Source={StaticResource locale}}" Style="{StaticResource textRadioStyle}"
                            IsChecked="{Binding DisplayMode, Converter={StaticResource modeToBool}, ConverterParameter={x:Static models:DisplayMode.Favorites}}">
                        <RadioButton.RenderTransform>
                            <TranslateTransform />
                        </RadioButton.RenderTransform>
                    </RadioButton>
                </StackPanel>
                <StackPanel x:Name="appButtonPanel" VerticalAlignment="Top" HorizontalAlignment="Right"
                        Margin="0,0,-4,0" Orientation="Horizontal">
                    <Button x:Name="logoutBtn" Content="{Binding rs.LogoutBtn, Source={StaticResource locale}}" Style="{StaticResource radioLikeButtonStyle}"
                            Command="{x:Static vm:Commands.LogoutCommand}">
                        <Button.RenderTransform>
                            <TranslateTransform />
                        </Button.RenderTransform>
                    </Button>
                </StackPanel>
            </Grid>

            <Grid x:Name="PwHeader" Grid.Row="1" Background="{DynamicResource TransparentChromeBrush}" Margin="4,0,4,0">
                <TextBlock Text="{Binding rs.AllPasswordsColumn, Source={StaticResource locale}}" Style="{StaticResource headerText}"
                        Visibility="{Binding DisplayMode, Converter={StaticResource modeToVis},ConverterParameter={x:Static models:DisplayMode.Passwords}}" />
                <ComboBox Padding="9,0,9,0" BorderThickness="0" SelectedItem="{Binding SelectedCategory}" FontSize="18"
                        DisplayMemberPath="Name" ItemsSource="{Binding Categories}"
                        Visibility="{Binding DisplayMode, Converter={StaticResource modeToVis},ConverterParameter={x:Static models:DisplayMode.Categories}}" />

                <TextBlock Text="{Binding rs.FavoritesText, Source={StaticResource locale}}" Style="{StaticResource headerText}"
                        Visibility="{Binding DisplayMode, Converter={StaticResource modeToVis},ConverterParameter={x:Static models:DisplayMode.Favorites}}" />
            </Grid>

            <!--    Passwords View-->
            <ListBox x:Name="passwordList" Grid.Row="2" ScrollViewer.CanContentScroll="False"
                    ScrollViewer.HorizontalScrollBarVisibility="Disabled" Margin="4,5,4,5" VerticalAlignment="Top"
                    HorizontalAlignment="Stretch" SelectedItem="{Binding SelectedPassword}"
                    ItemTemplate="{StaticResource compactPasswordTemplate}" ItemsSource="{Binding SelectedPasswords}" />

            <!-- Footer:  -->
            <Border BorderThickness="0,1,0,0" Grid.Row="3"  BorderBrush="{DynamicResource TransparentChromeBrush}">
                <StackPanel x:Name="appPanel" HorizontalAlignment="Center" Margin="10,8,10,0"
                    Orientation="Horizontal">
                    <StackPanel.Resources>
                        <Style TargetType="Button" BasedOn="{StaticResource textButtonStyle}">
                            <Setter Property="FontSize" Value="14" />
                        </Style>
                    </StackPanel.Resources>
                    <!--<Button Content="DELETE" Command="{x:Static vm:Commands.DeletePasswordCommand}" />
                    <Separator Style="{StaticResource lineSepStyle}" />
                    <Button x:Name="newPasswordBtn" Content="NEW" Command="{x:Static vm:Commands.NewPasswordCommand}" />
                    <Separator Style="{StaticResource lineSepStyle}" />
                    <Button Content="EDIT" Command="{x:Static vm:Commands.EditPasswordCommand}" />-->
                    <Button Content="{Binding rs.ShowPasswordBtn, Source={StaticResource locale}}" Command="{x:Static vm:Commands.ViewPasswordCommand}" />
                    <StackPanel.RenderTransform>
                        <TranslateTransform x:Name="footerTransform"/>
                    </StackPanel.RenderTransform>
                </StackPanel>
            </Border>

        </Grid>
        <ControlTemplate.Triggers>

            <DataTrigger Binding="{Binding AppDisplayMode}" Value="{x:Static models:AppDisplayMode.Passwords}">
                <DataTrigger.EnterActions>
                    <BeginStoryboard>
                        <Storyboard>
                            <DoubleAnimation Storyboard.TargetName="footerTransform" Storyboard.TargetProperty="Y" From="80" To="0" Duration="0:0:0.2">
                                <DoubleAnimation.EasingFunction>
                                    <ExponentialEase Exponent="5" EasingMode="EaseOut"/>
                                </DoubleAnimation.EasingFunction>
                            </DoubleAnimation>
                            <DoubleAnimation From="0" To="1" Storyboard.TargetName="appPanel"
                                    Storyboard.TargetProperty="Opacity" Duration="0:0:1"
                                    EasingFunction="{StaticResource easeOut}" />
                            <DoubleAnimation From="0" To="1" Storyboard.TargetName="tabPanel"
                                    Storyboard.TargetProperty="Opacity" Duration="0:0:1"
                                    EasingFunction="{StaticResource easeOut}" />
                            <DoubleAnimation From="-8" To="0" Storyboard.TargetName="alpha"
                                    Storyboard.TargetProperty="RenderTransform.X" Duration="0:0:1"
                                    EasingFunction="{StaticResource easeOut}" />
                            <DoubleAnimation From="-16" To="0" Storyboard.TargetName="catsSep"
                                    Storyboard.TargetProperty="RenderTransform.X" Duration="0:0:1"
                                    EasingFunction="{StaticResource easeOut}" />
                            <DoubleAnimation From="-24" To="0" Storyboard.TargetName="cats"
                                    Storyboard.TargetProperty="RenderTransform.X" Duration="0:0:1"
                                    EasingFunction="{StaticResource easeOut}" />
                            <DoubleAnimation From="-32" To="0" Storyboard.TargetName="favesSep"
                                    Storyboard.TargetProperty="RenderTransform.X" Duration="0:0:1"
                                    EasingFunction="{StaticResource easeOut}" />
                            <DoubleAnimation From="-40" To="0" Storyboard.TargetName="faves"
                                    Storyboard.TargetProperty="RenderTransform.X" Duration="0:0:1"
                                    EasingFunction="{StaticResource easeOut}" />

                            <DoubleAnimation From="0" To="1" Storyboard.TargetName="appButtonPanel"
                                    Storyboard.TargetProperty="Opacity" Duration="0:0:1"
                                    EasingFunction="{StaticResource easeOut}" />

                            <DoubleAnimation From="8" To="0" Storyboard.TargetName="logoutBtn"
                                    Storyboard.TargetProperty="RenderTransform.X" Duration="0:0:1"
                                    EasingFunction="{StaticResource easeOut}" />
                        </Storyboard>
                    </BeginStoryboard>
                </DataTrigger.EnterActions>
            </DataTrigger>

            <DataTrigger Binding="{Binding AppDisplayMode}" Value="{x:Static models:AppDisplayMode.Passwords}">
                <Setter  Property="controls:FocusContainer.IsFocused" Value="true" TargetName="passwordList" />
            </DataTrigger>

        </ControlTemplate.Triggers>

    </ControlTemplate>
    <!-- Resource dictionary entries should be defined here. -->
</ResourceDictionary>